<template>
  <div class="config-container">
    <h3>广告配置</h3>
    <el-form ref="formRef" :model="form" :rules="formRules" label-width="150px">
<!--      <el-form-item label="平台初始积分额度：">-->
<!--        {{ isToFixed(form.platform_total_point, 8) }}-->
<!--        <span class="remark">-->
<!--          <strong>积分</strong>（不可修改，系统初始化设置）-->
<!--        </span>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="每日权重空投额度：">-->
<!--        {{ isToFixed(form.every_day_put_int_point, 8) }}-->
<!--        <span class="remark">-->
<!--          <strong>积分</strong>-->
<!--          （不可修改，系统初始化设置）-->
<!--        </span>-->
<!--      </el-form-item>-->
      <el-form-item label="广告adpid：" prop="adp_id">
        <el-input-number v-model="form.adp_id" :min="0" :step="0.01" placeholder="请输入"></el-input-number>
        <span class="remark">

        </span>
      </el-form-item>
      <el-form-item label="每天观看次数：" prop="see_times_one_day">
        <el-input-number v-model="form.see_times_one_day" :min="0" placeholder="请输入"></el-input-number>
<!--        <span class="remark">-->
<!--          <strong>%</strong>-->
<!--          （积分转赠时按照此比例结算手续费，即转需销毁的积分比例）-->
<!--        </span>-->
      </el-form-item>
      <el-form-item label="每天平分zydc：" prop="zydc">
        <el-input-number v-model="form.zydc" :min="0" placeholder="请输入"></el-input-number>
<!--        <span class="remark">-->
<!--          <strong>%</strong>-->
<!--          （积分提现时按照此比例结算手续费，即转需销毁的积分比例）-->
<!--        </span>-->
      </el-form-item>
<!--      <el-form-item label="余额转积分手续费：" prop="balance_to_point_handling_fee_ratio">-->
<!--        <el-input-number v-model="form.balance_to_point_handling_fee_ratio" :min="0" :step="0.01" placeholder="请输入"></el-input-number>-->
<!--        <span class="remark">-->
<!--          <strong>%</strong>-->
<!--          （余额转积分时按照此比例结算手续费，即转需销毁的余额比例）-->
<!--        </span>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="激活周期：" prop="activation_period_day">-->
<!--        <el-input-number v-model="form.activation_period_day" :min="0" :step="1" placeholder="请输入"></el-input-number>-->
<!--        <span class="remark">-->
<!--          <strong>天</strong>-->
<!--          （超过激活周期未购物的用户，标记为未激活）-->
<!--        </span>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="赠送贡献值：" prop="register_give_consumption">-->
<!--        <el-input-number v-model="form.register_give_consumption" :min="0" :step="1" placeholder="请输入"></el-input-number>-->
<!--        <span class="remark">（注册用户送贡献值）</span>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="是否开始空投：" prop="open_put_in">-->
<!--        <el-radio v-model="form.open_put_in" :label="true">是</el-radio>-->
<!--        <el-radio v-model="form.open_put_in" :label="false">否</el-radio>-->
<!--      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" @click="saveForm()">保存</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import seviceApi from '@/api/serviceApi.js'
export default {
  data () {
    return {
      form: {
        open_put_in: false
      },
      formRules: {
        point_price: {
          required: true,
          message: '当日积分价值不能为空',
          trigger: 'blur'
        },
        give_away_handling_fee_ratio: {
          required: true,
          message: '转赠手续费不能为空',
          trigger: 'blur'
        },
        withdraw_handling_fee_ratio: {
          required: true,
          message: '提现手续费不能为空',
          trigger: 'blur'
        },
        balance_to_point_handling_fee_ratio: {
          required: true,
          message: '余额转积分手续费不能为空',
          trigger: 'blur'
        },
        activation_period_day: {
          required: true,
          message: '激活周期不能为空',
          trigger: 'blur'
        },
        register_give_consumption: {
          required: true,
          message: '赠送贡献值不能为空',
          trigger: 'blur'
        }
      }
    }
  },
  created () {
    this.getInfo()
  },
  methods: {
    getInfo () {
      seviceApi.getAdvConfig().then(res => {
        if (res && res.data.code == 200) {
          this.form = res.data.data
        }
      })
    },
    saveForm () {
      this.$refs.formRef.validate(valid => {
        if (valid) {
          seviceApi.saveAdvConfig(this.form).then(res => {
            if (res && res.data.code == 200) {
              this.getInfo()
              this.$message.success('保存成功')
            }
          })
        } else {
          this.$message.error('请将表单补充完整')
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.config-container {
  /deep/ .el-form {
    .el-form-item__label {
      font-weight: bold;
    }

    .el-input-number--medium {
      width: 300px;
    }

    .remark {
      margin-left: 20px;
    }
  }
}
</style>
